<!DOCTYPE html>



  


<html class="theme-next mist use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />







<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="基础控件,Toolbar," />










<meta name="description" content="前言在Android Studio中默认工程继承AppCompatActivity而不是Activity。从AppCompatActivity的源码中可以看到，它是继承自FragmentActivity的而它的另一个作用是代替了过时的ActionBarActivity，即用Toolbar代替ActionBar。接下来就介绍一下Toolbar的使用。">
<meta name="keywords" content="基础控件,Toolbar">
<meta property="og:type" content="article">
<meta property="og:title" content="Toolbar的使用">
<meta property="og:url" content="http://yoursite.com/2016/09/21/Toolbar的使用/index.html">
<meta property="og:site_name" content="SISYPHUSER">
<meta property="og:description" content="前言在Android Studio中默认工程继承AppCompatActivity而不是Activity。从AppCompatActivity的源码中可以看到，它是继承自FragmentActivity的而它的另一个作用是代替了过时的ActionBarActivity，即用Toolbar代替ActionBar。接下来就介绍一下Toolbar的使用。">
<meta property="og:locale" content="zh-Hans">
<meta property="og:image" content="http://7xtcmn.com1.z0.glb.clouddn.com/toolbar.png">
<meta property="og:image" content="http://7xtcmn.com1.z0.glb.clouddn.com/toolbar2.png">
<meta property="og:image" content="http://7xtcmn.com1.z0.glb.clouddn.com/toolbar3.png">
<meta property="og:image" content="http://7xtcmn.com1.z0.glb.clouddn.com/toolbar4.png">
<meta property="og:image" content="http://7xtcmn.com1.z0.glb.clouddn.com/toolbar5.png">
<meta property="og:image" content="http://7xtcmn.com1.z0.glb.clouddn.com/toolbar6.png">
<meta property="og:updated_time" content="2018-03-03T05:17:47.779Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Toolbar的使用">
<meta name="twitter:description" content="前言在Android Studio中默认工程继承AppCompatActivity而不是Activity。从AppCompatActivity的源码中可以看到，它是继承自FragmentActivity的而它的另一个作用是代替了过时的ActionBarActivity，即用Toolbar代替ActionBar。接下来就介绍一下Toolbar的使用。">
<meta name="twitter:image" content="http://7xtcmn.com1.z0.glb.clouddn.com/toolbar.png">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Mist',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://yoursite.com/2016/09/21/Toolbar的使用/"/>





  <title>Toolbar的使用 | SISYPHUSER</title>
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">SISYPHUSER</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-word">
          <a href="/word/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-calendar"></i> <br />
            
            word
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2016/09/21/Toolbar的使用/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Andy">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="SISYPHUSER">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">Toolbar的使用</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2016-09-21T08:35:29+08:00">
                2016-09-21
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Android/" itemprop="url" rel="index">
                    <span itemprop="name">Android</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <h2 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h2><p>在Android Studio中默认工程继承AppCompatActivity而不是Activity。<br><img src="http://7xtcmn.com1.z0.glb.clouddn.com/toolbar.png" alt="AppCompatActivity"><br>从AppCompatActivity的源码中可以看到，它是继承自FragmentActivity的而它的另一个作用是代替了过时的ActionBarActivity，即用Toolbar代替ActionBar。接下来就介绍一下Toolbar的使用。</p>
<a id="more"></a>
<p>导入依赖包<br>compile ‘com.android.support:appcompat-v7:24.1.1’</p>
<h2 id="xml中设置"><a href="#xml中设置" class="headerlink" title="xml中设置"></a>xml中设置</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">&lt;android.support.design.widget.AppBarLayout</span><br><span class="line">	android:layout_width=&quot;match_parent&quot;</span><br><span class="line">	android:layout_height=&quot;wrap_content&quot;&gt;</span><br><span class="line">	&lt;android.support.v7.widget.Toolbar </span><br><span class="line">	xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;</span><br><span class="line">		android:id=&quot;@+id/tool&quot;</span><br><span class="line">		android:layout_width=&quot;match_parent&quot;</span><br><span class="line">		android:layout_height=&quot;wrap_content&quot;</span><br><span class="line">		android:background=&quot;?attr/colorPrimary&quot;</span><br><span class="line">		android:minHeight=&quot;?attr/actionBarSize&quot;</span><br><span class="line">		android:theme=&quot;@style/ThemeOverlay.AppCompat.Dark.ActionBar&quot;</span><br><span class="line">		app:popupTheme=&quot;@style/ThemeOverlay.AppCompat.Light&quot;/&gt;</span><br><span class="line">&lt;/android.support.design.widget.AppBarLayout&gt;</span><br></pre></td></tr></table></figure>
<h2 id="在Activity中设置Toolbar"><a href="#在Activity中设置Toolbar" class="headerlink" title="在Activity中设置Toolbar"></a>在Activity中设置Toolbar</h2><h3 id="基本设置"><a href="#基本设置" class="headerlink" title="基本设置"></a>基本设置</h3><p>1.设置标题<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">setTitle(&quot;title&quot;);</span><br><span class="line">setSupportActionBar(toolbar);</span><br></pre></td></tr></table></figure></p>
<p>默认标题是靠右对齐，如果要居中或对标题样式有特殊需求可以在xml中的Toolbar标签中加入<textview>并配置其属性<br>2.设置返回按钮<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">tool.setNavigationIcon(R.mipmap.back);</span><br><span class="line">       tool.setNavigationOnClickListener(new View.OnClickListener() &#123;</span><br><span class="line">           @Override</span><br><span class="line">           public void onClick(View view) &#123;</span><br><span class="line">               Snackbar.make(getWindow().getDecorView(),&quot;back&quot;,Snackbar.LENGTH_SHORT).show();</span><br><span class="line">           &#125;</span><br><span class="line">       &#125;);</span><br></pre></td></tr></table></figure></textview></p>
<p>3.设置logo<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">tool.setLogo(R.mipmap.logo);</span><br></pre></td></tr></table></figure></p>
<p>4.设置副标题<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">tool.setSubtitle(&quot;subtitle&quot;);</span><br></pre></td></tr></table></figure></p>
<p>设置完以上参数的样式如下<br><img src="http://7xtcmn.com1.z0.glb.clouddn.com/toolbar2.png" alt="样式"></p>
<h3 id="menu设置"><a href="#menu设置" class="headerlink" title="menu设置"></a>menu设置</h3><p>1.menu基本设置<br>在代码中设置获取menu<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">@Override</span><br><span class="line">  public boolean onCreateOptionsMenu(Menu menu) &#123;</span><br><span class="line">      getMenuInflater().inflate(R.menu.food_type_menu,menu);</span><br><span class="line">      return true;</span><br><span class="line">  &#125;</span><br><span class="line"></span><br><span class="line">  @Override</span><br><span class="line">  public boolean onOptionsItemSelected(MenuItem item) &#123;</span><br><span class="line">      //各个item点击事件</span><br><span class="line">      return true;</span><br><span class="line">  &#125;</span><br></pre></td></tr></table></figure></p>
<p> 在menu中设置menu样式<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line"> &lt;menu xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;</span><br><span class="line">    xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;</span><br><span class="line">    &gt;</span><br><span class="line">    &lt;item</span><br><span class="line">        android:id=&quot;@+id/menu_group&quot;</span><br><span class="line">        android:title=&quot;item1&quot;</span><br><span class="line">        android:icon=&quot;@mipmap/ic_launcher&quot;</span><br><span class="line">        app:showAsAction=&quot;always&quot; /&gt;</span><br><span class="line">    &lt;item</span><br><span class="line">        android:id=&quot;@+id/menu_clear&quot;</span><br><span class="line">        android:title=&quot;item1&quot;</span><br><span class="line">        app:showAsAction=&quot;never&quot; /&gt;</span><br><span class="line">    &lt;item</span><br><span class="line">        android:id=&quot;@+id/menu_refresh&quot;</span><br><span class="line">        android:title=&quot;item2&quot;</span><br><span class="line">        app:showAsAction=&quot;never&quot; /&gt;</span><br><span class="line">&lt;/menu&gt;</span><br></pre></td></tr></table></figure></p>
<p>其中showAsAction属性共有五个值：ifRoom、never、always、withText、collapseActionView，可以混合使用。<br>ifRoom    会显示在Item中，但是如果已经有4个或者4个以上的Item时会隐藏在溢出列表中。当然个数并不仅仅局限于4个，依据屏幕的宽窄而定<br>never    永远不会显示。只会在溢出列表中显示，而且只显示标题，所以在定义item的时候，最好把标题都带上。<br>always    无论是否溢出，总会显示。<br>withText    withText值示意Action bar要显示文本标题。Action bar会尽可能的显示这个标题，但是，如果图标有效并且受到Action bar空间的限制，文本标题有可能显示不全。<br>collapseActionView      声明了这个操作视窗应该被折叠到一个按钮中，当用户选择这个按钮时，这个操作视窗展开。否则，这个操作视窗在默认的情况下是可见的，并且即便在用于不适用的时候，也要占据操作栏的有效空间。<br>一般要配合ifRoom一起使用才会有效果。</p>
<p>最终效果<br><img src="http://7xtcmn.com1.z0.glb.clouddn.com/toolbar3.png" alt=""></p>
<p><img src="http://7xtcmn.com1.z0.glb.clouddn.com/toolbar4.png" alt=""></p>
<p>2.menu样式<br>默认的样式是白底黑字，可以通过设置Toolbar中的theme来改变样式<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">&lt;!--&lt;style name=&quot;MenuStyle&quot; parent=&quot;@style/ThemeOverlay.AppCompat.Light&quot;&gt;--&gt;</span><br><span class="line">&lt;style name=&quot;MenuStyle&quot; parent=&quot;@style/ThemeOverlay.AppCompat.Dark.ActionBar&quot;&gt;</span><br><span class="line">    &lt;item name=&quot;android:textColorPrimary&quot;&gt;#ffffff&lt;/item&gt;</span><br><span class="line">&lt;/style&gt;</span><br></pre></td></tr></table></figure></p>
<p>以上两个parent，ThemeOverlay.AppCompat.Light为白色背景ThemeOverlay.AppCompat.Dark.ActionBar为黑色背景，android:textColorPrimary设置字体颜色<br>3.PopupMenu<br>PopupMenu是一个轻量话的控件，与PopupWindow相比少了很多自定义的属性，这里我将PopupWindow作为一个Menu的展开来使用<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line">PopupMenu popup=new PopupMenu(this,findViewById(R.id.menu_group));</span><br><span class="line">popup.getMenuInflater().inflate(R.menu.food_type_menu_item,popup.getMenu());</span><br><span class="line">popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() &#123;</span><br><span class="line">    @Override</span><br><span class="line">    public boolean onMenuItemClick(MenuItem item) &#123;</span><br><span class="line">        switch (item.getItemId())&#123;</span><br><span class="line">            case R.id.item1:</span><br><span class="line">                ToastUtil.showToast(FoodTypeActivity.this,&quot;item1&quot;);</span><br><span class="line">                break;</span><br><span class="line">            case R.id.item2:</span><br><span class="line">                ToastUtil.showToast(FoodTypeActivity.this,&quot;item2&quot;);</span><br><span class="line">                break;</span><br><span class="line">            &#125;</span><br><span class="line">        return true;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;);</span><br><span class="line">popup.show();</span><br></pre></td></tr></table></figure></p>
<p><img src="http://7xtcmn.com1.z0.glb.clouddn.com/toolbar5.png" alt=""></p>
<p>如果需要改变PopupMenu的字体颜色和背景颜色就需要在该window对应的Activity中改变它的style<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">&lt;style name=&quot;PpupmenuStyle&quot; parent=&quot;@style/AppTheme&quot;&gt;</span><br><span class="line">	&lt;item name=&quot;android:textColorPrimary&quot;&gt;#ffffff&lt;/item&gt;</span><br><span class="line">    &lt;item name=&quot;android:colorBackground&quot;&gt;#000000&lt;/item&gt;</span><br><span class="line">&lt;/style&gt;</span><br></pre></td></tr></table></figure></p>
<p>在AndroidManifest中设置style<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">&lt;activity android:name=&quot;.view.FoodTypeActivity&quot; android:theme=&quot;@style/PpupmenuStyle&quot;/&gt;</span><br></pre></td></tr></table></figure></p>
<p>默认PopupMenu是只显示title不显示icon的，可以自己重写PopupMenu并修改相关属性来使之显示icon<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">try &#123;</span><br><span class="line">	Field field = popup.getClass().getDeclaredField(&quot;mPopup&quot;);</span><br><span class="line">	field.setAccessible(true);</span><br><span class="line">	MenuPopupHelper mHelper = (MenuPopupHelper) field.get(popup);</span><br><span class="line">	mHelper.setForceShowIcon(true);</span><br><span class="line">&#125; catch (Exception e) &#123;</span><br><span class="line">	e.printStackTrace();</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></p>
<p><img src="http://7xtcmn.com1.z0.glb.clouddn.com/toolbar6.png" alt=""></p>
<h2 id="结尾"><a href="#结尾" class="headerlink" title="结尾"></a>结尾</h2><p>以上就是关于Toolbar的一些东西，虽然常用的都是自定义的title，但还是有必要了解一下官方给的方案。</p>

      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/基础控件/" rel="tag"># 基础控件</a>
          
            <a href="/tags/Toolbar/" rel="tag"># Toolbar</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2016/09/09/关于键盘的一切/" rel="next" title="关于键盘的一切">
                <i class="fa fa-chevron-left"></i> 关于键盘的一切
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2016/09/23/MVP模式/" rel="prev" title="MVP模式">
                MVP模式 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image"
                src="/images/avatar.gif"
                alt="Andy" />
            
              <p class="site-author-name" itemprop="name">Andy</p>
              <p class="site-description motion-element" itemprop="description">Something Wrong</p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives/">
              
                  <span class="site-state-item-count">18</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/categories/index.html">
                  <span class="site-state-item-count">6</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="/tags/index.html">
                  <span class="site-state-item-count">28</span>
                  <span class="site-state-item-name">标签</span>
                </a>
              </div>
            

          </nav>

          

          

          
          

          
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#前言"><span class="nav-number">1.</span> <span class="nav-text">前言</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#xml中设置"><span class="nav-number">2.</span> <span class="nav-text">xml中设置</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#在Activity中设置Toolbar"><span class="nav-number">3.</span> <span class="nav-text">在Activity中设置Toolbar</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#基本设置"><span class="nav-number">3.1.</span> <span class="nav-text">基本设置</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#menu设置"><span class="nav-number">3.2.</span> <span class="nav-text">menu设置</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#结尾"><span class="nav-number">4.</span> <span class="nav-text">结尾</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2018</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Andy</span>

  
</div>


  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Mist</a> v5.1.4</div>




        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.4"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  












  





  

  

  

  
  

  

  

  

</body>
</html>
